<template>
  <div style="display:flex;">
    <div><img src="../../img/1.jpg" style="width: 300px"></div>
    <div style="margin-left: 30px;display: flex">
      <div>
        <p>商品名：</p>
        <p>价格：</p>
        <p>库存剩余:</p>
        <p>颜色：</p>
      </div>
      <div style="margin-left: 30px">
        <p>{{shopName}}</p>
        <p>{{shopName}}</p>
        <p>{{shopName}}</p>
        <p><el-select v-model="classObj">
          <el-option v-for="item in classArray" :key="item.value" :label="item.name" :value="item.name"/>
        </el-select></p>
      </div>
    </div>
  </div>
  <div style="margin-left: 440px">
    <el-button type="primary" @click="$router.push('shopping')">加入购物车</el-button>
    <el-button type="success" @click="gouMai">直接购买</el-button>
  </div>
  <el-dialog
      v-model="showAdd"
      title="买单"
      width="30%"
  >
    <div>
      选择你的结算方式：
      <el-select v-model="classObj1" @change="buy">
        <el-option v-for="item in classArray1" :key="item.value" :label="item.name" :value="item.name"/>
      </el-select>
    </div>
    <template #footer>
      <span>
        <el-button @click="showAdd = false">取消</el-button>
        <el-button type="primary" @click="showAdd = false" v-if="queDing">
         前往
        </el-button>
      </span>
    </template>
  </el-dialog>
</template>

<script>
export default {
  data() {
    return {
      shopName:"棒棒糖",
      classObj:"红色",
      classArray:[{name:"红色"},{name:"蓝色"}],
      showAdd:false,
      classObj1:"",
      classArray1:[{name:"支付宝"},{name:"预存款"}],
      queDing:false,
    }
  },methods:{
    buy(){
      this.queDing = true
      if (this.classObj1 ===""){
        this.queDing =false
      }
    },
    gouMai(){
      this.showAdd = true
      this.classObj1 =""
      this.queDing =false
    }
  }
}
</script>

<style scoped>

</style>